//
//  JMPeripheralCell.m
//  OpenSesame
//
//  Created by zhangjiaming on 16/1/29.
//  Copyright © 2016年 OpenSesame. All rights reserved.
//

#import "JMPeripheralCell.h"

@implementation JMPeripheralCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        // 设置cell之间的分割线
        UIView *separater = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JMPhoneWidth, 1)];
        separater.backgroundColor = JMColor(242, 242, 242);
        [self.contentView addSubview:separater];
        
        // 设置外设名称Label
        UILabel *keyNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, JMPhoneWidth, 50)];
        keyNameLabel.textColor = JMColor(51, 51, 51);
        self.peripheralLabel = keyNameLabel;
        [self.contentView addSubview:keyNameLabel];
        
        self.height = 50;
        self.backgroundColor = [UIColor clearColor];
        
        // 设置选中时的状态颜色
        UIView *back = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JMPhoneWidth, 60)];
        back.backgroundColor = JMColor(245, 245, 245);
        self.selectedBackgroundView = back;
        self.selectionStyle = UITableViewCellSelectionStyleDefault;
    }
    
    return self;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *ID = @"peripheralCell";
    JMPeripheralCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[JMPeripheralCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
@end
